package lm.concurrency.pattern.arrunning;

import java.util.concurrent.locks.LockSupport;

/**
 * @Auther: Min.Liu
 * @Description:
 * @Date: Created in 10:38 2024/11/4
 */
class ParkUnpark {
    public void print(String str, Thread next) {
        for (int i = 0; i < loopNumber; i++) {
            LockSupport.park();
            System.out.print(str);
            LockSupport.unpark(next);
        }
    }

    private int loopNumber;

    public ParkUnpark(int loopNumber) {
        this.loopNumber = loopNumber;
    }
}
